package com.sskj.cndragon.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.cndragon.http.HttpConfig;
import com.sskj.cndragon.ui.activity.SendActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.bean.UserData;
import com.sskj.lib.http.JsonCallBack;


public class SendActivityPresenter extends BasePresenter<SendActivity> {

    public void checkUserMsg(String userMobile) {
        httpService.checkUserMsg(userMobile)
                .tag(this)
                .execute(new JsonCallBack<HttpData<UserData>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<UserData>> response) {
                        HttpData<UserData> body = response.body();
                        ToastUtil.showShort(body.getMsg());
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.getUserMsgOK(body.getData());
                        }
                    }
                });
    }

    public void sendCrystal(String userId, String num, String tel, String tradePed) {
        httpService.sendCrystal(userId, num, tel, MD5Util.getMd5Value(tradePed))
        .tag(this)
        .execute(new JsonCallBack<HttpData>(this) {
            @Override
            public void onSuccess(Response<HttpData> response) {
                HttpData body = response.body();
                ToastUtil.showShort(body.getMsg());
                if (body.getStatus() == HttpConfig.OK) {
                    mView.sendOK();
                }
            }
        });
    }
}
